<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_listadvinfo.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@page import="com.lmpop.trade.ts_category.Ts_categoryInfo" %>
<%@page import="com.lmpop.trade.ti_channel.*" %>	
<%
	request.setCharacterEncoding("UTF-8");
	Map ti_listadvinfo = new Hashtable();
	String _key_words = "",_adv_title="",_key_type="",s_start_date="",s_end_date="";

	ti_listadvinfo.put("key_words",9);
  if(request.getParameter("n_adv_title")!=null && !request.getParameter("n_adv_title").equals("")){
	_adv_title = request.getParameter("n_adv_title");
	ti_listadvinfo.put("adv_title",_adv_title);
	
  }
  
  if(request.getParameter("key_type")!=null && !request.getParameter("key_type").equals("")){
	 _key_type = request.getParameter("key_type");
	ti_listadvinfo.put("key_type",_key_type);

  }
  
  if(request.getParameter("sx_start_date")!=null && !request.getParameter("sx_start_date").equals("")){
	s_start_date = request.getParameter("sx_start_date");
	ti_listadvinfo.put("start_date",s_start_date);
	}
	if(request.getParameter("sx_end_date")!=null && !request.getParameter("sx_end_date").equals("")){
 	s_end_date = request.getParameter("sx_end_date");
	ti_listadvinfo.put("end_date",s_end_date);
	}
	
	
		Ts_categoryInfo  ts_categoryInfo  = new Ts_categoryInfo();
	
	  Ti_channelInfo channelinfo = new Ti_channelInfo();	   
	  

	Ti_listadvinfoInfo ti_listadvinfoInfo = new Ti_listadvinfoInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_listadvinfoInfo.getListByPageSort(ti_listadvinfo,Integer.parseInt(iStart),limit);
	int counter = ti_listadvinfoInfo.getCountByObjSort(ti_listadvinfo);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?key_words="+_key_words+"&iStart=",Integer.parseInt(iStart),limit);
	String para =	"key_words="+_key_words+"&n_adv_title="+_adv_title+"&key_type="+_key_type+"&sx_start_date="+s_start_date+"&sx_end_date="+s_end_date+"&iStart="+Integer.parseInt(iStart)+"&limit="+limit;	

%>
<html>
  <head>
    
    <title>分类广告管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
	<script type="text/javascript" src="/js/commen.js"></script>
	<script language="javascript" type="text/javascript" src="js_listAdv.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>分类广告管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su" >
		<tr>
			<td align="left" >
				&nbsp;广告名称:<input name="n_adv_title" type="text"  maxLength="50"/>
				&nbsp;关键字类型:<select name="key_type" id="key_type" >
													<option value="">请选择</option>
													<option value=0>商品</option><option value=1>卖家</option><option value=2>资讯</option>
												</select>
				<div>
					&nbsp;发布时间:<input name="sx_start_date" id="sx_start_date" type="text" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'sx_end_date\',{d:-1})}',readOnly:true})"  class="Wdate" maxlength="10" />
					-
					<input name="sx_end_date" id="sx_end_date" type="text"  onclick="WdatePicker({minDate:'#F{$dp.$D(\'sx_start_date\',{d:1})}',readOnly:true})"  class="Wdate"  value="" maxlength="10" />
			
						<input name="searchInfo" type="button" value="搜索" onclick="searchForm()"/>	
				</div>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe" >
		<tr><td align="center" bgcolor="#ECE6E6"><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td >
				共计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center">
				<input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
		  	
		  	<th>广告名称</th>
		  	  	
		  	<th> 关键字类型</th>
		  	
		  	<th width="20%">广告范围</th>
		  	
		  	<th width="15%">发布时间</th>
		  	
				<th width="10%">修改</th>
	  		<th width="10%">删除</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
  			Hashtable map = (Hashtable)list.get(i);
  			String adv_id="",key_type="",adv_rang="",key_words="",adv_title="",adv_text="",start_date="",end_date="",adv_post="",price="",adv_url="",contact="",contact_info="",user_id="",in_date="",remark="";
			String key_types="";
			Map catMap = new Hashtable();
			
			String cust_rang_str="";
			
			
		if(map.get("adv_id")!=null) adv_id = map.get("adv_id").toString();
  	if(map.get("key_type")!=null) key_type = map.get("key_type").toString();
  	if(map.get("adv_rang")!=null) adv_rang = map.get("adv_rang").toString();  	
  	if(key_type.equals("0")) 
  	{
  		key_types="金色钥匙分类广告"; 
  		catMap = ts_categoryInfo.getCatClassMap("12");
  		if(catMap.get(adv_rang)!=null)
      {
      	cust_rang_str = catMap.get(adv_rang).toString();       
	    }
  	}
  	 if(key_type.equals("1")) 
  	{
	  	key_types="卖家";
	  	catMap = ts_categoryInfo.getCatClassMap("1"); 
	  	if(catMap.get(adv_rang)!=null)
      {
 			 	cust_rang_str = catMap.get(adv_rang).toString();       
      }  
  	}
  	if(key_type.equals("2"))
  	{
  	 key_types="资讯";
  	 cust_rang_str =channelinfo.getChName(adv_rang); 
  	}
  	

	 	if(map.get("key_words")!=null) key_words = map.get("key_words").toString();
  	if(map.get("adv_title")!=null) adv_title = map.get("adv_title").toString();
  	if(adv_title.length()>25) adv_title=adv_title.substring(0,25);
  	if(map.get("adv_text")!=null) adv_text = map.get("adv_text").toString();
  	if(map.get("start_date")!=null) start_date = map.get("start_date").toString();
		if(start_date.length()>19)start_date=start_date.substring(0,19);
  	if(map.get("end_date")!=null) end_date = map.get("end_date").toString();
		if(end_date.length()>19)end_date=end_date.substring(0,19);
  	if(map.get("adv_post")!=null) adv_post = map.get("adv_post").toString();
  	if(map.get("price")!=null) price = map.get("price").toString();
  	if(map.get("adv_url")!=null) adv_url = map.get("adv_url").toString();
  	if(map.get("contact")!=null) contact = map.get("contact").toString();
  	if(map.get("contact_info")!=null) contact_info = map.get("contact_info").toString();
  	if(map.get("user_id")!=null) user_id = map.get("user_id").toString();
  	if(map.get("in_date")!=null) in_date = map.get("in_date").toString();
		if(in_date.length()>19)in_date=in_date.substring(0,19);
  	if(map.get("remark")!=null) remark = map.get("remark").toString();

		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=adv_id %>" /></td>
			
		  	
		  	<td><a href="updateInfo.jsp?adv_id=<%=adv_id %>&<%=para%>"><%=adv_title%></a></td>
		  		<td> <%=key_types%></td>
		  		
		  		<td width="20%">
		  				<%=cust_rang_str%>
		  	</td>
		  	
		   	<td width="15%"><%=in_date%></td>
		  	
			<td width="10%"><a href="updateInfo.jsp?adv_id=<%=adv_id %>&<%=para%>"><img src="/program/admin/images/edit.gif" title="修改" /></a></td>
	  	<td width="10%"><a href="javascript:delOneNews('<%=adv_id%>');"><img border="0" src="/program/admin/images/delete.gif" title="删除" /></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td >
				共计:<%=counter %>条
			</td>
		</tr>
	</table>	<table width="100%" cellpadding="0" class="tablehe" cellspacing="0" border="0">
		<tr><td align="center" bgcolor="#ECE6E6"><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="7074" />
	  
		<input type="hidden" name="key_words" id="key_words" value="" />
	  </form>
</body>

</html>
